package com.ruoyi.web.controller.system;

import java.util.List;

import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TmcActivityUser;
import com.ruoyi.system.service.ITmcActivityUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社区中间
Controller
 * 
 * @author ruoyi
 * @date 2021-04-21
 */
@RestController
@RequestMapping("/system/activityuser")
public class TmcActivityUserController extends BaseController
{
    @Autowired
    private ITmcActivityUserService tmcActivityUserService;

    /**
     * 查询社区活动中间列表
     */
    //@PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(TmcActivityUser tmcActivityUser)
    {
        startPage();
        List<TmcActivityUser> list = tmcActivityUserService.selectTmcActivityUserList(tmcActivityUser);
        return getDataTable(list);
    }

    /**
     * 导出社区活动中间列表
     */
    //@PreAuthorize("@ss.hasPermi('system:user:export')")
    @Log(title = "社区活动中间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TmcActivityUser tmcActivityUser)
    {
        List<TmcActivityUser> list = tmcActivityUserService.selectTmcActivityUserList(tmcActivityUser);
        ExcelUtil<TmcActivityUser> util = new ExcelUtil<TmcActivityUser>(TmcActivityUser.class);
        return util.exportExcel(list, "user");
    }

    /**
     * 获取社区活动中间详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tmcActivityUserService.selectTmcActivityUserById(id));
    }

    /**
     * 新增社区活动中间
     */
    //@PreAuthorize("@ss.hasPermi('system:user:add')")
    @Log(title = "社区活动中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TmcActivityUser tmcActivityUser)
    {
        return toAjax(tmcActivityUserService.insertTmcActivityUser(tmcActivityUser));
    }

    /**
     * 修改社区活动中间
     */
    //@PreAuthorize("@ss.hasPermi('system:user:edit')")
    @GetMapping("/queryListById")
    public AjaxResult queryListById(@Param("activityId") Long activityId,@Param("publicuserId") Long publicuserId)
    {
        return AjaxResult.success(tmcActivityUserService.queryListById(activityId,publicuserId));
    }
    /**
     * 修改社区活动中间
     */
    //@PreAuthorize("@ss.hasPermi('system:user:edit')")
    @GetMapping("/queryListByuserId")
    public AjaxResult queryListByuserId(Long id)
    {
        return AjaxResult.success(tmcActivityUserService.queryListByuserId(id));
    }

    /**
     * 删除社区活动中间
     */
    //@PreAuthorize("@ss.hasPermi('system:user:remove')")
    @Log(title = "社区活动中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tmcActivityUserService.deleteTmcActivityUserByIds(ids));
    }
}
